package ReSofting.it.GoldDirector;

import ReSofting.it.GoldDirector.Db.DataDbManager;
import ReSofting.it.GoldDirector.Helpers.resVarie;
import ReSofting.it.GoldDirector.Model.GlobalDatas;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class GoldDirectorActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        
        setButtonsHandlers();
        
        impostaDateTime();
        
        getNetSettings();
        
    }//fM
    

	 private void getNetSettings() {
		
		 DataDbManager dbMan = new  DataDbManager(this);
		 
		 GlobalDatas.NetSettings =  dbMan.getNetSettingsFromDb();
		 
		 dbMan.CloseDb();
		 dbMan = null;
		
	}


	//Menues*********************************************************
   @Override 
   public boolean onCreateOptionsMenu(Menu menu) {	
   	return resVarie.onCreateOptionsMenu(menu, this);
   }//fM


   @Override
   public boolean onOptionsItemSelected(MenuItem item) {	
   	return resVarie.handlerMenu(item, this);	 
   } //fm
    
    
    private void impostaDateTime()
    {
    	TextView vv = (TextView)  findViewById(R.id.startTextCurrentDateTime); 
    	vv.setText(resVarie.getCurrentDateTime().format("%d/%m/%y %T"));
    }

	private void setButtonsHandlers() {
		
		 Button startBtnInvio = (Button)  findViewById(R.id.buttonStartInvio);	     
		 startBtnInvio.setOnClickListener(new OnClickListener() {
	            public void onClick(View view) {    
	            	startActivity(resVarie.orderItemsView);   //                  
	            	}
	            });
		 
		 
		 Button startBtnRicez = (Button)  findViewById(R.id.buttonStartRicezione);	     
		 startBtnRicez.setOnClickListener(new OnClickListener() {
	            public void onClick(View view) {    
	            	startActivity(resVarie.orderItemsView);   //                  
	            	}
	            });
		 
		 
		Button settingsBtn = (Button)  findViewById(R.id.buttonSettings);	     
		settingsBtn.setOnClickListener(new OnClickListener() {
	            public void onClick(View view) {    
	            	startActivity(resVarie.settingsView);   //                  
	            	}
	            }
	            );
		
	}//fM
	
	
	
	
	
}//fC